package com.canbot.u05.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.canbot.u05.R;
import com.canbot.u05.bean.Brow;

import java.util.List;

/**
 * 选择表情适配器
 * Created by XH on 2017/3/3.
 */

public class ChooseSpeechAdapter extends BaseAdapter {

        private Context mContext;

        List<Brow> mbrowList;


        public ChooseSpeechAdapter(Context context, List<Brow> browList) {
                mContext = context;
                mbrowList = browList;
        }

        @Override
        public int getCount() {
                return mbrowList.size();
        }

        @Override
        public Object getItem(int position) {
                return mbrowList.get(position);
        }

        @Override
        public long getItemId(int position) {
                return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
                ViewHolder holder;
                if (convertView == null) {
                        holder = new ViewHolder();
                        convertView = LayoutInflater.from(mContext).inflate(R.layout.choose_speech_item, null);
                        holder.speechName = (Button) convertView.findViewById(R.id.speech_icon_item_btn);
                        holder.speechName.setText(mbrowList.get(position).getName());
                        convertView.setTag(holder);
                }
                else {
                        holder = (ViewHolder) convertView.getTag();
                        holder.speechName.setText(mbrowList.get(position).getName());
                }

                return convertView;
        }

        class ViewHolder {

                public Button speechName;
        }

}
